﻿<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Search Sample</title>
        <script src="searchClient.js" type="text/javascript"></script>
        <script src="layoutLibrary.js" type="text/javascript"></script>
        <script language='javascript' type="text/javascript">
            //
            // instantiate a searchclient by 
            // - passing in the id of the div to show instructions as the first parameter
            // - passing in the id of the div to show search results as the second parameter
            // - passing in the scope to search, by following the (site:xxx OR ) syntax
            //
            var sc = new searchClient('keyAndCount', 'returnArea', "");

            //
            // register events
            //
            window.onload=winLoad;
            window.onresize=winResize;

            function winLoad() {
                document.getElementById("keyword").focus();
                winResize();
            }

            function winResize() {
                var oReturn = document.getElementById('returnArea');
                var oKeyAndCount = document.getElementById('keyAndCount');
                var util = new layoutLibrary();
                var oReturnHeight = 
                    (
                        util.getWindowHeight() - 
                        (util.getOffsetTop(oKeyAndCount) + oKeyAndCount.offsetHeight) -
                        50
                    ) + "px";
                oReturn.style.height = oReturnHeight;
            }

            function searchOnKeyPress(e) {
                if (e.keyCode == 13) {
                    sc.search(document.getElementById("keyword").value);
                    return false;
                } else {
                    return true;
                }
            }
        </script>
    </head>
    <body>
        <table>
            <tr>
                <td>
                    <input 
                        type="text" 
                        id="keyword" 
                        title="Enter search keywords"
                        size="30" 
                        onkeypress="return searchOnKeyPress(event)"
                        value="" />
                </td>
                <td>
                    <input 
                        type="button"
                        onclick="sc.search(document.getElementById('keyword').value);"
                        value="Search" />
                </td>
            </tr>
        </table>
        <div class="CommonContentArea">
            <div class="CommonContent">
                <div    id="keyAndCount">
                    Enter search keywords
                </div>
                <hr />
                <div    id="returnArea" 
                        style="overflow:auto;height:auto">
                </div>	
            </div>
        </div>
    </body>
</html>